package com.huisang.springboot.exception;

import com.huisang.springboot.utils.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

//定义其为异常控制器
@ControllerAdvice
public class ExceptionHandlerManage {

    @ExceptionHandler(ServiceException.class)
    @ResponseBody
    public Result handle(ServiceException se) {
        Result result = new Result();
        result.setCode(se.getCode());
        result.setMessage(se.getMessage());
        return result;
    }
}
